//
//  OrderDetailView.m
//  
//
//  Created by chris on 15/12/26.
//
//

#import "OrderDetailView.h"
#import "DataModel.h"
#import "NSDate+Utils.h"
#import "OrderVc.h"
#import "UIViewController+order.h"

@implementation OrderDetailView

- (void)setInfo:(OrderDealModel *)model {
    self.orderNumLa.text =     [NSString ignoreEmptyStr:model.id];
    self.statusLa.text =  [NSString ignoreEmptyStr:[_vc getOrderStatusNameFromtypeId:model.type.intValue andSignId:model.sign.intValue]];
    self.typeLa.text =    [NSString ignoreEmptyStr:[_vc getOrderTypeNameFromtypeId:model.type.intValue]];
    self.dateLa.text =    [[NSDate dateWithString:model.creatTime formatString:@"yyyyMMddHHmmss"] formatStringWithFormat:@"yyyy-MM-dd"];//20151202111348  2015-12-12

    //申请数目
    self.channelLa.text = @"";
}

- (void)setOrderContentInfo:(OrderDealDetailOrderContentInfo *)orderContentInfo {
//    self.channelLa.text = [NSString ignoreEmptyStr:o];
}

- (instancetype)initWithFrame:(CGRect)frame type:(NSString *)type
{
    self = [super initWithFrame:frame];
    if (self)
    {
        NSArray * titles = nil;
        if ([type isEqualToString:@"新建"])
        {
            titles = @[@"工单号：",@"工单状态：",@"类型：",@"创建时间："];
        }
        else
        {
            titles = @[@"工单号：",@"工单状态：",@"类型：",@"创建时间：",@"渠道编号："];

        }
        for (int i = 0; i < titles.count; i++)
        {
            UILabel * titleLa = [[UILabel alloc]initWithFrame:CGRectMake1(10, 15+(5+15)*i,65, 15)];
            //            titleLa.backgroundColor = [UIColor redColor];
            titleLa.textColor = [UIColor lightGrayColor];
            titleLa.font = font(13);
            titleLa.text = titles[i];
            [self addSubview:titleLa];
            
            
            UILabel * contentLa = [[UILabel alloc]initWithFrame:CGRectMake1(75, 15+(5+15)*i, DEF_SCREEN_WIDTH-105, 15)];
//                        contentLa.backgroundColor = [UIColor lightGrayColor];
            if (i == 0)
            {
                contentLa.textColor = [UIColor colorWithRed:0.13 green:0.06 blue:0.6 alpha:1];
            }
            else
            {
                contentLa.textColor = [UIColor blackColor];
            }
            contentLa.font = font(13);
            switch (i)
            {
                case 0:
                    _orderNumLa = contentLa;
                    break;
                case 1:
                    _statusLa = contentLa;
                    break;
                case 2:
                    _typeLa = contentLa;
                    break;
                case 3:
                    _dateLa = contentLa;
                    break;
                case 4:
                    _channelLa = contentLa;
                    break;
                default:
                    break;
            }
            [self addSubview:contentLa];
        }
    }
    return self;
}
CG_INLINE CGRect
CGRectMake1(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
    CGRect rect;
    rect.origin.x = x*ratio_width; rect.origin.y = y*ratio_heigth;
    rect.size.width = width*ratio_width; rect.size.height = height*ratio_heigth;
    return rect;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
